home *** CD-ROM | disk | FTP | other *** search
/ 500 MB Nyheder Direkte fra Internet 2 / 500 MB nyheder direkte fra internet CD 2.iso / start / data / text / dbase.txt < prev    next >
Text File  |  1994-09-21  |  87KB  |  1,870 lines

  1.  
  2.            GET COMFORTABLE
  3.   DBASE is a programming language that lets you easily manipulate 
  4. random-access files and databases. Invented by Wayne Ratliff, was 
  5. published by Ashton-Tate, which sold over a million copies. In 
  6. 1991, Borland bought Ashton-Tate, so now DBASE is published by 
  7. Borland.
  8.  
  9.           Versions of DBASE
  10.   The original version of DBASE was called DBASE 2. It ran on the 
  11. IBM PC and also on computers using the CP/M operating system.
  12.   Then came an improvement called DBASE 3, then DBASE 3+, then 
  13. DBASE 4, then DBASE 4 version 1.1, then DBASE 4 version 1.5, then 
  14. DBASE 4 version 2, then DBASE 5. Those improvements run just on 
  15. the IBM PC (and clones). Two versions of DBASE 5 are available: 
  16. one for DOS, the other for Windows.
  17.   A company called Fox Software invented DBASE versions that run 
  18. faster, contain extra features, and cost less! Microsoft bought 
  19. Fox Software, so now Fox's versions are published by Microsoft.
  20.   Fox's versions of DBASE are called FOXBASE (which resembles 
  21. DBASE 3), FOXBASE+ (which resembles DBASE 3+), FOXPRO (which 
  22. resembles DBASE 4), and FOXPRO 2 (which goes beyond DBASE 4), 
  23. FOXPRO 2.5 (which goes even further), and FOXPRO 2.6 (which goes 
  24. even further).
  25.   Two versions of FOXPRO 2.6 are available: one for DOS, the 
  26. other for Windows. A Mac version of FOXPRO 2.6 isn't available 
  27. yet, but you can get a Mac version of FOXPRO 2.5.
  28.   Discount dealers sell each of those versions (FOXPRO 2.6 DOS, 
  29. FOXPRO 2.6 Windows, and FOXPRO 2.5 Mac) for about $90, though 
  30. that temporary low price will probably rise.
  31.  
  32.        What's in this chapter
  33.   I'll explain how to use DBASE 4 version 1.5. (Newer versions of 
  34. DBASE are similar.)
  35.   I'll also explain the differences in DBASE 3, DBASE 3+, DBASE 4 
  36. version 1.1, and FOXPRO 2. (Newer versions of FOXPRO are similar 
  37. to FOXPRO 2.)
  38.  
  39.         Hardware requirements
  40.   Fancy versions (such as DBASE 4, FOXBASE+, FOXPRO, and FOXPRO 
  41. 2) require a hard disk. If you lack a hard disk, use DBASE 3 or 
  42. 3+.
  43.   DBASE 4 requires 640K of RAM. FOXPRO and FOXPRO 2 require 512K. 
  44. If you don't have so much RAM, use DBASE 3 or 3+, which require 
  45. just 384K.
  46.   To use FOXPRO 2's advanced commands, you need at least 1½M of 
  47. RAM and either a 386 or 486 CPU. To use FOXPRO 2 easily, you need 
  48. a mouse.
  49.  
  50.         Copy to the hard disk
  51.   When you buy DBASE 4 version 1.5, you get a big box that 
  52. contains five manuals, four 1.2M floppies, and five 720K 
  53. floppies. (If your disk drive needs 360K floppies instead, you
  54. can get them by mailing Borland $15 extra.)
  55.                                          Here's how to copy DBASE 
  56. 4 version 1.5 onto your hard disk. (But if you're sharing the 
  57. computer, ask your colleagues whether they did this step 
  58. already!)
  59.                                          Turn on the computer 
  60. without any floppy in drive A. When you see the C prompt, put the 
  61. DBASE Install Disk into drive A. Type ``a:''. You'll see an A 
  62. prompt. Type ``install''.
  63.                                          The computer will say 
  64. ``DBASE 4 Installation''. Press ENTER twice.
  65.                                          The computer will say 
  66. ``Software Registration''. Type your name and press ENTER. Type 
  67. your company's name (if any) and press ENTER. Type your serial 
  68. number, which is on the label of the 5¼-inch DBASE Install Disk. 
  69. (If you remove that disk from the drive to peek at the serial 
  70. number, put that disk back in the drive when you finish peeking.)
  71.                                          While holding down the 
  72. Ctrl key, press the END key.
  73.                                          The computer will ask, 
  74. ``Do you wish to install caching?'' To keep the installation 
  75. procedure simple, press N.
  76.                                          When the computer tells 
  77. you, insert the other DBASE disks, and press ENTER after each 
  78. insertion.
  79.                                          The computer will say, 
  80. ``DBASE 4 can be run from any directory if your AUTOEXEC.BAT file 
  81. contains the necessary information.'' To keep your AUTOEXEC.BAT 
  82. file simple, press the Esc key.
  83.                                          The computer will say, 
  84. ``DBASE 4 will not run properly unless adequate file and buffer 
  85. space is reserved.'' Press ENTER. The computer will make your 
  86. CONFIG.SYS file says ``files=99''.
  87.                                          The computer will say, 
  88. ``The installation of DBASE 4 is complete.'' Press ENTER.
  89.                                          Turn off the computer so 
  90. you can start fresh.
  91.                                           Old versions DBASE 3 
  92. comes on three 360K disks. The first disk is the program itself; 
  93. the second disk is a spare copy of the program, in case the first 
  94. disk gets damaged; the third disk contains examples and 
  95. utilities.
  96.                                          DBASE 3+ comes on seven 
  97. 360K disks. Two disks contain the program itself, and the other 
  98. five disks are supplementary.
  99.                                          Instead of copying DBASE 
  100. 3 or 3+ to the hard disk, try using the procedures described in 
  101. the next section.
  102.                                          DBASE 4 version 1.1 
  103. comes on ten 360K disks, which you install by using a procedure 
  104. similar to DBASE version 1.5.
  105.                                           FOXPRO 2 When you buy 
  106. FOXPRO 2, you get a big box that contains nine manuals and four 
  107. 1.2M disks.
  108.                                          Here's how to copy 
  109. FOXPRO 2 onto your hard disk. (I assume you have a 386 or 486, at 
  110. least 1½M of RAM, and a mouse. I assume you've practiced using 
  111. the mouse with other software, such as Windows or Deluxe Paint.)
  112.                                          Turn on the computer 
  113. without any floppy in drive A. When you see the C prompt, put 
  114. FOXPRO Disk 1 into drive A. Type ``a:install''.
  115.                                          The computer will say, 
  116. ``Fox Software Product Installation''. Press ENTER 6 times.
  117.                                          The computer will say, 
  118. ``Enter your FOXPRO Serial Number''. Type the Serial Number 
  119. (which came on a sheet of paper enclosed with the disks).
  120.                                          The computer will say, 
  121. ``Enter your FOXPRO Activation Key''. Type the hidden Activation 
  122. Key (which is hidden on the SECOND sheet of paper enclosed with 
  123. the disks; do NOT type the DEMONSTRATION Activation Key).
  124.                                          The computer will say, 
  125. ``Please insert Disk #2''. Insert FOXPRO Disk 2 into drive A, and 
  126. press ENTER.
  127.                                          The computer will say, 
  128. ``Please insert Disk #3''. Insert FOXPRO Disk 3 into drive A, and 
  129. press ENTER three times.
  130.                                          The computer will say, 
  131. ``Programs To Install''. Using the mouse, click the ``Check All'' 
  132. button, then click the ``Install'' button.
  133.                                          The computer will say, 
  134. ``Please insert Disk #4''. Insert FOXPRO Disk 4 into drive A, and 
  135. press ENTER.
  136.                                          The computer will say, 
  137. ``Installation Complete''. Press ENTER.
  138.                                          Turn off the computer so 
  139. you can start fresh.
  140.              Start DBASE
  141.   To start using DBASE 4, turn on the computer without any floppy 
  142. in drive A.
  143.   If you've put the DO.BAT file onto your hard disk (as I 
  144. recommended in the MS-DOS chapter), type ``do dbase''. If you 
  145. have not put DO.BAT onto your hard disk, you must type ``cd 
  146. dbase'' and then ``dbase''.
  147.   (If you're using DBASE 4 version 1.0 or 1.1, the computer will 
  148. say ``This software is licensed''. Press ENTER.)
  149.   The computer will say ``DBASE 4 CONTROL CENTER''. Press the Esc 
  150. key. The computer will ask, ``Are you sure?'' Press the Y key.
  151.   At the screen's lower left corner, you'll see a period, which 
  152. is called the dot prompt. After the dot prompt, you can type any 
  153. DBASE command you wish.
  154.   Press the CAPS LOCK key, so any commands you type will be 
  155. capitalized.
  156.    Old versions Here's how to start using DBASE 3 and 3+.
  157.   Without putting any DBASE floppies into the drives, turn on the 
  158. computer. Wait for a DOS prompt to appear.
  159.   Put DBASE System Disk 1 in drive A.
  160.   Make sure you see an A prompt. (If you're using a hard disk, do 
  161. that by typing ``a:'' after the C prompt.)
  162.   Peculiarity: if you're using DBASE 3+ version 1.1 and nobody's 
  163. ever used your System Disk 1 before, you must give it an ``ID'' 
  164. by following the instructions in the ``Getting Started'' booklet 
  165. that came with the disk.
  166.   Regardless of which version of DBASE 3+ you're using, your next 
  167. step is to type ``dbase'' after the A prompt.
  168.   If the bottom of the screen says ``Press ENTER to assent to the 
  169. License Agreement'', press ENTER. If the computer says ``Insert 
  170. System Disk 2'', do so and press ENTER. If the bottom right 
  171. corner of the screen says ``Exit ___ Esc'', press the Esc key.
  172.   At the screen's lower left corner, you'll see a period, which 
  173. is the dot prompt. Press the CAPS LOCK key, so any commands you 
  174. type will be capitalized.
  175.   If you have a hard disk, type ``SET DEFAULT TO C''. If you lack 
  176. a hard disk, put a blank formatted disk in drive B and type ``SET 
  177. DEFAULT TO B''.
  178.    FOXPRO 2 Here's how to start using FOXPRO 2.
  179.   Turn on the computer without any floppy in drive A.
  180.   When you see the C prompt, type ``cd foxpro2''. When you see 
  181. the FOXPRO2 prompt, type ``foxprox''. (If you don't have enough 
  182. RAM to run ``foxprox'', type ``fox'' instead.)
  183.   In the middle of the screen, you'll see a rectangle that has 
  184. the word ``Command'' at the top of it. That rectangle is called 
  185. the ``Command Window''. To move that rectangle to a different 
  186. part of the screen, use the mouse: point at the word ``Command'', 
  187. and drag it. To change the rectangle's size, point at the dot in 
  188. the rectangle's bottom right corner, and drag it.
  189.   For best results, drag until the rectangle consumes most of the 
  190. top third of the screen.
  191.   Press the CAPS LOCK key, so any commands you type will be 
  192. capitalized.
  193.  
  194.                                                     Arithmetic
  195.                                          If you want the computer 
  196. to print the answer to 5+2, say ``? 5+2'' after the dot prompt, 
  197. so your screen looks like this:
  198. . ? 5+2
  199. The computer will print:
  200.          7
  201.                                          Notice that DBASE, like 
  202. BASIC, uses a question mark to mean print. So ``? 5+2'' means: 
  203. print 5+2. In DBASE, you must use the question mark; do not type 
  204. the word PRINT.
  205.                                          DBASE, like BASIC, uses 
  206. the symbols +, -, *, /, ^, E, and parentheses.
  207.                                          Unfortunately, DBASE 
  208. gives the wrong answer to -5^2. According to mathematicians, -5^2 
  209. means ``the negative of 5^2'', which is ``the negative of 25'', 
  210. which is -25. DBASE mistakenly thinks that -5^2 means ``the 
  211. square of -5'' and therefore prints 25.
  212.                                           FOXPRO 2 You don't see 
  213. a dot prompt. Just type:
  214. ? 5+2
  215. Your typing will appear in the Command Window. At the end of your 
  216. typing, when you press the ENTER key, the computer will print 
  217. this answer at the screen's bottom:
  218.  7
  219.  
  220.                                                       Strings
  221.                                          DBASE, like BASIC, lets 
  222. you use quotation marks to create strings. So if you say ___ 
  223. . ? "I LOVE YOU"
  224. the computer will print:
  225. I LOVE YOU
  226.  
  227.                                                Multiple computations
  228.                                          You can print several 
  229. computations on the same line. For example, if you say ___ 
  230. . ? 2+3,2-3,2*3,2/3
  231. the computer will print:
  232.          5         -1          6          0.67
  233.  
  234.                                                        QUIT
  235.                                          When you finish using 
  236. DBASE, do not turn off the computer's power. Turning off the 
  237. power will wreck the data files you've been working on.
  238.                                          Instead of turning off 
  239. the power, say QUIT, so your screen looks like this:
  240. . QUIT
  241.                                          That QUIT command makes 
  242. the computer put the finishing touches on all your data files. 
  243. Then the computer will stop using DBASE, and will say:
  244. C:\>
  245.                                          After the ``C:\>'', you 
  246. can give any DOS command, or turn off the power.
  247.  
  248.          CREATE A DATA FILE
  249.   Let's create a data file about families in your neighborhood. 
  250. Begin by saying:
  251. . CREATE FAMILIES
  252. That makes the computer create, on your disk, a data file named 
  253. ``FAMILIES.DBF''. (The ``.DBF'' stands for ``Data Base File''.)
  254.  
  255.          Complete the chart
  256.   Let's store each family's NAME, annual INCOME, and POPULATION 
  257. (number of people in the family). Suppose the longest family NAME 
  258. is Anagnostopoulos, the highest INCOME is 125000.00, and the 
  259. largest POPULATION is 13 (because the family includes a mother, 
  260. father, and 11 kids).
  261.   To prepare the computer to handle such data, feed the computer 
  262. this chart:
  263. ┌─────┬────────────┬────────────┬───────┬─────┬───────┐
  264. │ Num │ Field Name │ Field Type │ Width │ Dec │ Index │
  265. ╞═════╪════════════╪════════════╪═══════╪═════╪═══════╡
  266. │   1 │ NAME       │ Character  │   15  │     │   N   │
  267. │   2 │ INCOME     │ Numeric    │    9  │   2 │   N   │
  268. │   3 │ POPULATION │ Numeric    │    2  │   0 │   N   │
  269. │     │            │            │       │     │       │
  270. │     │            │            │       │     │       │
  271. └─────┴────────────┴────────────┴───────┴─────┴───────┘
  272.   The second column says that for each family we're storing these 
  273. fields: the family's NAME, INCOME, and POPULATION. The left 
  274. column numbers those fields: 1, 2, and 3. The third column says 
  275. that each family's NAME is a string of characters, and that each 
  276. family's INCOME and POPULATION are numbers. The remaining columns 
  277. say that each NAME can be up to 15 characters long (such as 
  278. ``Anagnostopoulos''), each INCOME can be up to 9 symbols long 
  279. (such as 125000.00) and has 2 digits after the decimal point, 
  280. each POPULATION can be up to 2 digits long (such as 13) and has 
  281. no decimals, and No field is indexed.
  282.   As soon as you say CREATE FAMILIES (and press the ENTER key at 
  283. the end of that line), the computer asks you to feed it that 
  284. chart. To help you start, the computer puts this on the screen:
  285. ┌─────┬────────────┬────────────┬───────┬─────┬───────┐
  286. │ Num │ Field Name │ Field Type │ Width │ Dec │ Index │
  287. ╞═════╪════════════╪════════════╪═══════╪═════╪═══════╡
  288. │   1 │            │ Character  │       │     │   N   │
  289. │     │            │            │       │     │       │
  290. │     │            │            │       │     │       │
  291. │     │            │            │       │     │       │
  292. │     │            │            │       │     │       │
  293. └─────┴────────────┴────────────┴───────┴─────┴───────┘
  294. Just fill in all the other entries in the chart ___ and press the 
  295. ENTER key after each entry. Here are the details. . . . 
  296.   Begin by typing NAME (by pressing the N key, then A, then M, 
  297. then E). Press the ENTER key at the end of that entry.
  298.   Since the computer's already typed the next entry for you 
  299. (Character), press the ENTER key again.
  300.   Type the next entry (15). Press ENTER.
  301.   Since the computer's already typed the next entry for you (N), 
  302. press the ENTER key again.
  303.   Type the next entry (INCOME). Press ENTER.
  304.   Start typing the next entry (Numeric). As soon as you type the 
  305. N of Numeric, the computer automatically types the ``umeric'' for 
  306. you and presses the ENTER key for you.
  307.   Type the next entry (9); press ENTER. Type the next entry (2); 
  308. press ENTER. Accept the N, by pressing ENTER again.
  309.                                          Type the next entry 
  310. (POPULATION). Since POPULATION is so long, when you finish typing 
  311. it the computer will automatically beep (to warn you not to make 
  312. it even longer!) and press ENTER for you.
  313.                                          Type the next entry (N) 
  314. and the next entry (2); press ENTER. Type the final entry (0). 
  315. Since you've finished typing the entire table, tap the END key 
  316. while holding down the CONTROL key.
  317.                                           Old versions DBASE 3 
  318. and 3+ omit the Num and Index columns. DBASE 3 says Char/text 
  319. instead of Character. When you tap the END key wwhile holding 
  320. down the CONTROL key, DBASE 3+ says ``Press ENTER to confirm''; 
  321. DBASE 3 says ``Hit RETURN to confirm''; obey those versions by 
  322. pressing the ENTER/RETURN key.
  323.                                           FOXPRO 2 Feed the 
  324. computer this chart:
  325.   Name         Type    Width    Dec
  326. ┌──────────────────────────────────┐
  327. │NAME        Character   15        │
  328. │INCOME      Numeric      9       2│
  329. │POPULATION  Numeric      2       0│
  330. │                                  │
  331. │                                  │
  332. └──────────────────────────────────┘
  333.                                          Begin by typing NAME. 
  334. Press the TAB key at the end of that entry.
  335.                                          Since the computer's 
  336. already typed the next entry for you (Character), press the TAB 
  337. key again.
  338.                                          Type the next entry 
  339. (15). Press TAB.
  340.                                          Type the next entry 
  341. (INCOME). Press TAB.
  342.                                          Start typing the next 
  343. entry (Numeric). As soon as you type the N of Numeric, the 
  344. computer automatically types the ``umeric'' for you and presses 
  345. the TAB key for you.
  346.                                          Type the next entry (9); 
  347. press TAB. Type the next entry (2); press TAB. Type the next 
  348. entry (POPULATION); press TAB. Type the next entry (N) and the 
  349. next entry (2). The computer will automatically type the final 0.
  350.                                          Using the mouse, click 
  351. the word ``OK''.
  352.  
  353.            Input the data
  354.   The computer will ask:
  355. Input data records now? (Y/N)
  356. Tap the Y key, which means Yes.
  357.   On the screen, you'll see this:
  358. NAME                       
  359. INCOME            .  
  360. POPULATION    
  361. Notice that the NAME box is wide enough to hold 15 characters, 
  362. the INCOME box already includes the decimal point, and the 
  363. POPULATION box is wide enough to hold a 2-digit number.
  364.   Fill in the boxes. Here's how.
  365.   Type the first family's name (SMITH). As you type SMITH, you'll 
  366. see it appear in the first box. When you finish typing SMITH, 
  367. press ENTER.
  368.   Type family's income (24100.19). As you type 24100.19, you'll 
  369. see it appear in the second box. When you type the decimal point, 
  370. the number will automatically slide toward the right edge of the 
  371. box, so that the decimal point you typed is at the same place as 
  372. the decimal point that was already in the box. When you finish 
  373. typing the number, the computer will automatically beep and move 
  374. you to the third box.
  375.   Type the family's population (4). You'll see it appear in the 
  376. third box.
  377.   When you press the ENTER key afterwards, the computer will 
  378. record what you typed. Then the boxes will become blank again, so 
  379. that you can enter a second family's data.
  380.   After entering the second family's data (and pressing the ENTER 
  381. key if necessary), the screen will go blank again, so you can 
  382. enter a third family's data.
  383.   Enter data for as many families as you wish.
  384.   When you've typed the data for the last family, and you're 
  385. still looking at that data on the screen, tap the END key while 
  386. holding down the CONTROL key.
  387.   The computer will display the dot prompt, so that you can give 
  388. another DBASE command.
  389.    FOXPRO 2 When you finish typing an entry (such as SMITH), you 
  390. can press either the ENTER key or the TAB key.
  391.   In a numeric field (such as INCOME), you don't see the decimal 
  392. point until you type it.
  393.   When you finish typing the first family's data, that data does 
  394. NOT disappear from the screen; instead, the computer lets you 
  395. type the second family's data underneath the first family's.
  396.   When you finish typing the last family's data, click the close 
  397. box (which is the yellow square in the window's top left corner).
  398.  
  399.  
  400.             SEE YOUR DATA
  401.                                          After you've created a 
  402. data file, you can say:
  403. . LIST
  404. That makes the computer list your file's information onto the 
  405. screen, so the screen will look like this:
  406. Record#  NAME               INCOME POPULATION
  407.       1  SMITH            24100.19          4
  408.       2  ANAGNOSTOPOULOS  65143.26          5
  409.       3  SANCHEZ          50000.00         13
  410.       4  JONES             9873.00          2
  411.       5  SZCZEPANKIEWICZ 125000.00          4
  412.       6  SANTINI          -4130.15          4
  413.       7  WONG             15691.18          3
  414.                                          Notice that the Sanchez 
  415. family has a high income (50000.00) but must split it among 13 
  416. people (mother, father, and 11 kids). The Jones family's 
  417. population is just 2: a single mother and her baby. The Santini 
  418. family's income is a negative number this year, because the 
  419. family invested big money in the stock market and lost.
  420.  
  421.                                                 Choose your columns
  422.                                          You can make the 
  423. computer omit some of the columns. If you say ___ 
  424. . LIST NAME,POPULATION
  425. the computer will list the NAME and POPULATION columns but not 
  426. the INCOME column; it will list this:
  427. Record#  NAME            POPULATION
  428.       1  SMITH                    4
  429.       2  ANAGNOSTOPOULOS          5
  430.       3  SANCHEZ                 13
  431.       4  JONES                    2
  432.       5  SZCZEPANKIEWICZ          4
  433.       6  SANTINI                  4
  434.       7  WONG                     3
  435.                                          If you say ___ 
  436. . LIST POPULATION,NAME
  437. the computer will list the POPULATION column before the NAME 
  438. column, like this:
  439. Record#  POPULATION NAME
  440.       1           4 SMITH
  441.       2           5 ANAGNOSTOPOULOS
  442.       3          13 SANCHEZ
  443.       4           2 JONES
  444.       5           4 SZCZEPANKIEWICZ
  445.       6           4 SANTINI
  446.       7           3 WONG
  447.                                          If you say ___ 
  448. . LIST OFF POPULATION,NAME
  449. the computer will turn off the ``Record#'' column; it will list 
  450. just this:
  451. POPULATION NAME
  452.          4 SMITH
  453.          5 ANAGNOSTOPOULOS
  454.         13 SANCHEZ
  455.          2 JONES
  456.          4 SZCZEPANKIEWICZ
  457.          4 SANTINI
  458.          3 WONG
  459.  
  460.   For each family, let's compute the income per person. To do 
  461. that, divide the family's income by the family's population. To 
  462. display the income per person, and everything else, say ___ 
  463. . LIST NAME,INCOME,POPULATION,INCOME/POPULATION
  464. The computer will list this:
  465. Record#  NAME               INCOME POPULATION INCOME/POPULATION
  466.       1  SMITH            24100.19          4           6025.05
  467.       2  ANAGNOSTOPOULOS  65143.26          5          13028.65
  468.       3  SANCHEZ          50000.00         13           3846.15
  469.       4  JONES             9873.00          2           4936.50
  470.       5  SZCZEPANKIEWICZ 125000.00          4          31250.00
  471.       6  SANTINI          -4130.15          4          -1032.54
  472.       7  WONG             15691.18          3           5230.39
  473.  
  474.                     LIST FOR
  475.   To list just the low-income families (earning under $10,000), 
  476. say:
  477. . LIST FOR INCOME<10000
  478. The computer will list:
  479. Record#  NAME               INCOME POPULATION
  480.       4  JONES             9873.00          2
  481.       6  SANTINI          -4130.15          4
  482.   To list just the high-income families (earning at least 
  483. $50,000), say:
  484. . LIST FOR INCOME>=50000
  485. That means: list for INCOME greater than or equal to $50,000.
  486.   When you're comparing strings, an equal sign means ``begins 
  487. with''. So to list every family whose NAME begins with ``SAN'', 
  488. say:
  489. . LIST FOR NAME="SAN"
  490. The computer will list all data about SANCHEZ and SANTINI.
  491.   To list every family whose NAME does not begin with ``SAN'', 
  492. say ___ 
  493. . LIST FOR NAME<>"SAN"
  494. or, if you prefer, say:
  495. . LIST FOR NAME#"SAN"
  496.   To list just the ``SAN'' families whose incomes are high, say:
  497. . LIST FOR NAME="SAN" .AND. INCOME>=50000
  498. That makes the computer list the data for SANCHEZ (whose income 
  499. is 50000) but not SANTINI (whose income is -4130.15). Notice you 
  500. must put periods around the word AND.
  501.   DBASE also understands the word OR, which you must surround 
  502. with periods.
  503.   If you want to change DBASE, so that an equal sign between 
  504. strings means ``exactly equals'' instead of ``begins with'', say:
  505. . SET EXACT ON
  506. The SET EXACT ON command remains in effect until you say QUIT or 
  507. SET EXACT OFF.
  508.    FOXPRO 2 You can omit the periods around AND and OR. For 
  509. example, you can say either ``.AND.'' or ``AND''; the computer 
  510. doesn't care.
  511.  
  512.                  LIST STRUCTURE
  513.   If you say ___ 
  514. . LIST STRUCTURE
  515. the computer will say:
  516. Field  Field name  Type       Width    Dec    Index
  517.     1  NAME        Character     15               N
  518.     2  INCOME      Numeric        9      2        N
  519.     3  POPULATION  Numeric        2               N
  520. ** Total **                      27
  521. The computer will also say that the file contains 7 records, and 
  522. it will say the date the file was last changed.
  523.                                                     Compute the statistics
  524.                                                      The computer 
  525. can do statistics.
  526.                                                      COUNT If you 
  527. say ___ 
  528. . COUNT
  529. the computer will count how many records are in the file. It will 
  530. say:
  531.       7 records
  532.                                                      SUM If you 
  533. say ___ 
  534. . SUM
  535. the computer will sum all the numbers in the file. It will say:
  536.       7 records summed
  537.        INCOME POPULATION
  538.     285677.48         35
  539.                                                      That means: 
  540. the sum of all the incomes is $285,677.48, and the sum of all the 
  541. populations is 35. So altogether, your entire neighborhood earns 
  542. a total of $285,677.48, and the neighborhood's total population 
  543. is 35.
  544.                                                      AVERAGE If 
  545. you say ___ 
  546. . AVERAGE
  547. the computer will average all the numbers in the file. It will 
  548. say:
  549.       7 records averaged
  550.        INCOME POPULATION
  551.      40811.07          5
  552.                                                      That means 
  553. the average family INCOME is $40,811.07, and the average family 
  554. POPULATION is 5. (The average family population would be much 
  555. lower if the Sanchez family didn't have 13 members.)
  556.                                                      Restrictions 
  557. After the word COUNT, SUM, or AVERAGE, you can add restrictions.
  558.                                                      For example, 
  559. if you want to find the average of just the SANCHEZ and SANTINI 
  560. families, say:
  561. . AVERAGE FOR NAME="SAN"
  562. The computer will say:
  563.       2 records averaged
  564.        INCOME    POPULATION
  565.      22934.93          8.50
  566.                                                      If you want 
  567. to average just the incomes, and don't want to bother averaging 
  568. the populations, say:
  569. . AVERAGE INCOME FOR NAME="SAN"
  570.                                                       Old 
  571. versions When you say AVERAGE FOR NAME=``SAN'', the average 
  572. population is exactly 8.5, but DBASE 3 and 3+ make the computer 
  573. shorten the answer and say just 8.
  574.                                                       FOXPRO 2 
  575. When you say AVERAGE FOR NAME=``SAN'', the average population is 
  576. exactly 8.5, but the computer rounds the answer and says 9.
  577.  
  578.            Print on paper
  579.   To print on paper, you can use several tricks.
  580.   The simplest is to tap the PRINT SCREEN key. (If your keyboard 
  581. doesn't have a PRINT SCREEN key, press the PrtSc key while 
  582. holding down the SHIFT key.) That makes the printer print a 
  583. snapshot of what's on the screen.
  584.   Another way is to type:
  585. . SET PRINT ON
  586. Afterwards, anything that will appear on the screen will also 
  587. appear on paper simultaneously. The SET PRINT ON command remains 
  588. in effect until you say SET PRINT OFF.
  589.   To LIST on paper, you can say:
  590. . SET PRINT ON
  591. . LIST
  592. . SET PRINT OFF
  593.   A faster way to LIST onto paper is to say:
  594. . LIST TO PRINT
  595.    Old versions If you say LIST TO PRINT while using DBASE 3+, 
  596. the last line of the listing gets temporarily lost, in a part of 
  597. RAM called the ``buffer''. That last line won't get transferred 
  598. to paper until afterwards, when you give your next print-to-paper 
  599. command, or when you say SET PRINT ON.
  600.    FOXPRO 2 If you say SET PRINT ON, anything that will appear 
  601. on the screen's bottom line will appear on paper simultaneously. 
  602. (Saying SET PRINT ON will NOT make the paper show what's in the 
  603. Command Window.)
  604.  
  605.        Interrupt the computer
  606.   If the computer is doing something you don't like, and you want 
  607. to stop the computer, press the ESCAPE key (which says ``Esc'' on 
  608. it). That makes the computer abort what it was doing.
  609.   For example, suppose you say LIST, and the computer starts 
  610. printing a long listing. If you get impatient and don't want to 
  611. see the rest of the listing, press the ESCAPE key.
  612.   In some situations, when you press the ESCAPE key, the computer 
  613. asks:
  614. Cancel  Ignore  Suspend
  615. Confirm that you want to cancel: press the C key.
  616.   After the computer aborts, it displays the dot prompt, so you 
  617. can give another DBASE command.
  618.   In DBASE, as in IBM's BASIC and PC-DOS, you can make the 
  619. computer pause by pressing the PAUSE key. (If your keyboard 
  620. doesn't have a PAUSE key, tap the NUM LOCK key while holding down 
  621. the CONTROL key.) To make the computer continue where it left 
  622. off, press the SPACE bar.
  623.   If you say DISPLAY ALL instead of LIST, the computer will list 
  624. the file but will automatically pause at the end of each 
  625. screenful. At the end of each screenful, it will say, ``Press any 
  626. key to continue''. When you press ENTER, the computer will 
  627. continue on to the next screenful.
  628.   Short-cut: instead of saying DISPLAY ALL FOR NAME=``SAN'', you 
  629. can say DISPLAY FOR NAME=``SAN''. Here's the rule: before the 
  630. word FOR, you can omit ALL.
  631.    Old versions Instead of saying ``Cancel Ignore Suspend'', 
  632. DBASE 3+ says ``Cancel, Ignore, or Suspend? (C, I, or S)''; DBASE 
  633. 3 says ``Terminate command file?'', to which you respond by 
  634. tapping the Y key.
  635.  
  636.                                              Grab a particular record
  637.                                          To list just the 3rd 
  638. record say:
  639. . LIST RECORD 3
  640. The computer will say:
  641. Record#  NAME               INCOME POPULATION
  642.       3  SANCHEZ          50000.00         13
  643.                                          Instead of saying LIST 
  644. RECORD 3, you can say:
  645. . GO 3
  646. . DISPLAY
  647. That makes the computer GO to record #3 and DISPLAY it. That pair 
  648. of lines (GO 3 and DISPLAY) has exactly the same effect as saying 
  649. LIST RECORD 3.
  650.                                          After you've gotten the 
  651. record, you can use that record's NAME, INCOME, and POPULATION 
  652. for further computations. For example, if you say ___ 
  653. . ? INCOME/20
  654. the computer will print that record's INCOME divided by 20, which 
  655. is:
  656.       2500
  657.                                          To go to record #1, 
  658. which is the top record, you can say either GO 1 or GO TOP. If 
  659. your file contains 7 records, and you want to go to record #7, 
  660. which is the bottom record, you can say either GO 7 or GO BOTTOM. 
  661. (After giving a GO command, remember to say DISPLAY.)
  662.                                          If you're lazy, you can 
  663. usually omit the word GO. Instead of saying ___ 
  664. . GO 3
  665. you can say just:
  666. . 3
  667. But you cannot omit the GO from ``GO TOP'' and ``GO BOTTOM''.
  668.                                          SKIP SKIP means ``go to 
  669. the next record''.
  670.                                          For example, suppose 
  671. you've been looking at record #3 (because you said GO 3 and 
  672. DISPLAY), and you want to go to the next record, which is record 
  673. #4. Just say:
  674. . SKIP
  675. . DISPLAY
  676.                                          If you say SKIP 2, the 
  677. computer will skip ahead 2 records. For example, if you've been 
  678. looking at record #4 and then say SKIP 2, the computer will go to 
  679. record #6.
  680.                                          If you say SKIP -1, the 
  681. computer will skip back to the previous record. For example, if 
  682. you've been looking at record #6 and then say SKIP -1, the 
  683. computer will go back to record #5.
  684.                                          LOCATE If you say ___ 
  685. . LOCATE FOR NAME="SAN"
  686. . DISPLAY
  687. the computer will start at the first record, and keep hunting 
  688. until it finds a record whose NAME begins with ``SAN''. Then it 
  689. will DISPLAY that record:
  690. Record#  NAME               INCOME POPULATION
  691.       3  SANCHEZ          50000.00         13
  692.                                          To find the next 
  693. ``SAN'', say:
  694. . CONTINUE
  695. . DISPLAY
  696. The computer will display:
  697. Record#  NAME               INCOME POPULATION
  698.       6  SANTINI          -4130.15         13
  699.  
  700.   If you say CONTINUE again, the computer will continue hunting 
  701. for SAN's. If the computer reaches the end of the file and still 
  702. hasn't found another SAN, it will give up, and say:
  703. End of LOCATE scope
  704.    Old versions DBASE 3 and 3+ say just ``End of LOCATE''; they 
  705. omit the word ``scope''.
  706.  
  707.       Attach fancy restrictions
  708.   If you say:
  709. . GO 3
  710. . DISPLAY
  711. the computer will display just the 3rd record. If you say ___ 
  712. . GO 3
  713. . DISPLAY NEXT 2
  714. the computer will display 2 records (the 3rd and the 4th). If you 
  715. say ___ 
  716. . GO 3
  717. . DISPLAY NEXT 4
  718. the computer will display 4 records (the 3rd, 4th, 5th, and 6th). 
  719. If you say ___ 
  720. . GO 3
  721. . DISPLAY REST
  722. the computer will display the 3rd record and all the records that 
  723. come after it. For example, if the data file contains 7 records, 
  724. the computer will display the 3rd, 4th, 5th, 6th, and 7th 
  725. records. (If your data file is long, the computer will pause at 
  726. the end of each screenful, and wait for you to tell it to 
  727. continue. If you don't want such pauses, say LIST instead of 
  728. DISPLAY.)
  729.   If you say ___ 
  730. . GO 3
  731. . DISPLAY WHILE INCOME<100000
  732. the computer will start with the 3rd record, and continue 
  733. displaying records as long as INCOME <100000. Here are the 
  734. details. . . . 
  735.   The computer starts with the 3rd record, sees that its INCOME 
  736. is less than 100000, and displays that record. Then the computer 
  737. checks the 4th record, sees its INCOME is less than 100000, and 
  738. displays that record. Then the computer checks the 5th record, 
  739. sees its INCOME is not less than 100000, and refuses to display 
  740. the 5th record. The computer stops there, and refuses to look at 
  741. any more records. so the only records it displays are the 3rd and 
  742. 4th.
  743.   Those four commands ___ DISPLAY and DISPLAY NEXT and DISPLAY 
  744. REST and DISPLAY WHILE ___ are all affected by where you said to 
  745. GO. Three different commands ___ DISPLAY ALL and DISPLAY RECORD 
  746. and DISPLAY FOR ___ are unaffected by GO. Even if you said GO 3, 
  747. a DISPLAY ALL will display the entire file, DISPLAY RECORD 2 will 
  748. display record #2, and DISPLAY FOR INCOME<100000 will display all 
  749. the records whose INCOMEs are less than 100000.
  750.   The words NEXT, REST, WHILE, ALL, RECORD, and FOR are called 
  751. restrictions. You can attach a restriction to any DBASE command 
  752. that scans data records. For example, you can add a restriction 
  753. to DISPLAY, LIST, COUNT, SUM, AVERAGE, and LOCATE.
  754.    Old versions DBASE 3 doesn't understand the word REST.
  755.  
  756.  
  757.           REVISE YOUR DATA
  758.                                          To revise your data, you 
  759. can say EDIT, BROWSE, REPLACE, APPEND, INSERT, DELETE, or ZAP.
  760.  
  761.                                                        EDIT
  762.                                          To edit record #3, say 
  763. ___ 
  764. . EDIT RECORD 3
  765. or say ___ 
  766. . EDIT 3
  767. or say:
  768. . GO 3
  769. . EDIT
  770.                                          The computer will 
  771. display the 3rd record on the screen and let you edit it. While 
  772. you edit, you can use the four arrow keys (to move around the 
  773. screen), the BACKSPACE key (to erase the previous character), the 
  774. DELETE key (to delete the current character), and the INSERT key 
  775. (to switch from ``replacing'' to ``inserting'' and back to 
  776. ``replacing'' again). DBASE handles those keys the same way as 
  777. good word processors (such as Word Perfect, Q&A's word processor, 
  778. and DOS 5's EDIT).
  779.                                          To erase all the data in 
  780. a field, just move to that field (by using the arrow keys); then 
  781. tap the Y key while holding down the CONTROL key.
  782.                                          After editing the 3rd 
  783. record, if you press the PAGE DOWN key, the computer will let you 
  784. edit the 4th record. If you press the PAGE DOWN key again, the 
  785. computer will let you edit the 5th record. (Exception: if a 
  786. record is too long to fit on the screen, pressing the PAGE DOWN 
  787. key will get you to the next screenful of the same record.)
  788.                                          By pressing the PAGE UP 
  789. key, you can return to earlier records. For example, if you've 
  790. been editing the 5th record and then press the PAGE UP key, the 
  791. computer will let you re-edit the 4th record.
  792.                                          When you've finished 
  793. editing all the records you wish, tap the END key while holding 
  794. down the CONTROL key. Then the computer will display the dot 
  795. prompt, so you can type another DBASE command.
  796.                                           FOXPRO 2 While you're 
  797. editing the 3rd record, the screen also shows the 4th and 5th 
  798. records. When you finishing editing the 3rd record, you can move 
  799. to the 4th record by either pressing the PAGE DOWN key once or by 
  800. pressing the down-arrow key several times.
  801.                                          When you finish editing 
  802. all the records you wish, you can either press CONTROL with END 
  803. or click the close box (the yellow square in the window's top 
  804. left corner).
  805.  
  806.                                                       BROWSE
  807.                                          To see several records 
  808. on the screen simultaneously, so you can edit them all at once, 
  809. say:
  810. . GO 1
  811. . BROWSE
  812. That makes the computer LIST the first several records in your 
  813. file. The computer will let you use the arrow keys to move 
  814. through the list and edit your data. To hop right to the next 
  815. field, press the TAB key; to hop left to the previous field, 
  816. press the TAB key while holding down the SHIFT key.
  817.                                          The computer will list 
  818. as many records as can fit on the screen; to see the next 
  819. screenful of records, press the PAGE DOWN key. The computer will 
  820. list as many fields as can fit across the screen; to see other 
  821. fields, tap the right-arrow key while holding down the CONTROL 
  822. key.
  823.   When you've finished editing the data, tap the END key while 
  824. holding down the CONTROL key.
  825.    Old versions In DBASE 3 and 3+, the TAB key doesn't work. 
  826. Instead, hop to the next field by pressing END; hop back to the 
  827. previous field by pressing HOME.
  828.    FOXPRO 2 The computer will list as many fields as fit across 
  829. the window. To see other fields, press the TAB key several times.
  830.   The computer will list as many records as fit in the window. To 
  831. see other records, press the PAGE DOWN key once or twice (or 
  832. press the down-arrow key several times).
  833.   When you've finished editing the data, click the close box (or 
  834. press CONTROL with END).
  835.  
  836.                REPLACE
  837.   A more literary way to edit records is to type a sentence that 
  838. begins with the word REPLACE.
  839.   For example, to change record #3's INCOME to $60,000, say:
  840. . GO 3
  841. . REPLACE INCOME WITH 60000
  842. To increase record #5's INCOME by $700, say:
  843. . GO 5
  844. . REPLACE INCOME WITH INCOME+700
  845. To increase everybody's INCOME by $700, say:
  846. . REPLACE ALL INCOME WITH INCOME+700
  847. To increase the INCOME of just families whose NAME begins with 
  848. ``SAN'', say:
  849. . REPLACE FOR NAME="SAN" INCOME WITH INCOME+700
  850.  
  851.                APPEND
  852.   To add extra records, say:
  853. . APPEND
  854. The computer will display a blank record on the screen, and let 
  855. you fill it in.
  856.   For example, if your data file contains 7 records, and you say 
  857. APPEND, the computer will let you type record #8. When you finish 
  858. typing it (and press the ENTER key at the end of the last field), 
  859. the computer will let you type record #9, then record #10, etc.
  860.   When you've finished typing all the records you want to add, 
  861. tap the END key while holding down the CONTROL key. Then the 
  862. computer will display the dot prompt, so you can type another 
  863. DBASE command.
  864.    FOXPRO 2 When you've finished typing all the records you want 
  865. to add, click the close box (or press CONTROL with END).
  866.  
  867.                INSERT
  868.   To insert an extra record between record #3 and record #4, say:
  869. . GO 3
  870. . INSERT
  871. The computer will display a blank record on your screen, and let 
  872. you fill it in. When you finish filling it in, tap the END key 
  873. while holding down the CONTROL key. The new record that you typed 
  874. will become record #4; the old record #4 will become record #5; 
  875. the old record #5 will become record #6; etc.
  876.   The computer will then display the dot prompt, so you can type 
  877. another DBASE command.
  878.    FOXPRO 2 When you finish filling in the record, click the 
  879. close box (or press CONTROL with END).
  880.  
  881.                                                       DELETE
  882.                                          To delete records 3, 5, 
  883. and 6, say:
  884. . DELETE RECORD 3
  885. . DELETE RECORD 5
  886. . DELETE RECORD 6
  887. . PACK
  888.                                          Here's why. When you 
  889. give the DELETE commands, the computer makes notes about which 
  890. records you want to delete. But it doesn't actually delete those 
  891. records, until you say PACK.
  892.                                          When you say PACK, the 
  893. computer finally deletes those records. It also renumbers all the 
  894. other records, to fill the gaps left by the records you deleted.
  895.                                          Renumbering all the 
  896. records takes a long time; so while the computer's doing a PACK, 
  897. you should take your coffee break or lunch break. If you don't 
  898. want to take a break yet, delay saying PACK until later. Say PACK 
  899. at the end of the day, or when it's time to QUIT or to switch to 
  900. a different file.
  901.                                          DELETE without PACK If 
  902. you say to DELETE some records, but you haven't said PACK yet, 
  903. what happens when you try to LIST the file? The listing will show 
  904. an asterisk next to each record you said to delete. The 
  905. asterisked records will disappear later, when you say PACK.
  906.                                          If you say ___ 
  907. . SET DELETED ON
  908. the computer hides the asterisked records, so they don't appear 
  909. in listings and don't affect the COUNT or SUM or AVERAGE. But 
  910. although the asterisked records are hidden, they're still in the 
  911. file, until you say PACK.
  912.                                          SET DELETED ON remains 
  913. in effect until you say QUIT or SET DELETED OFF.
  914.                                          RECALL If you say DELETE 
  915. RECORD 3 and then change your mind, you can get the record back 
  916. by saying RECALL RECORD 3. But RECALL works only if you haven't 
  917. said PACK yet.
  918.                                          Short cuts Instead of 
  919. saying DELETE RECORD 3, you can say:
  920. . GO 3
  921. . DELETE
  922. Here's another way to delete record 3: get that record onto your 
  923. screen (by saying EDIT or BROWSE, and playing with the PAGE UP 
  924. and PAGE DOWN keys); and while you're looking at that record, tap 
  925. the U key while holding down the CONTROL key. (The U stands for 
  926. Undo.)
  927.                                          To delete everybody 
  928. whose name begins with ``SAN'', say:
  929. . DELETE FOR NAME="SAN"
  930. . PACK
  931.  
  932.                                                         ZAP
  933.                                          To delete all the 
  934. records, instead of saying DELETE ALL and PACK, just say:
  935. . ZAP
  936. Then the computer asks whether you're sure; tap the Y key. Then 
  937. the computer ZAPs the file, so that all the records are gone. But 
  938. the computer will still remember how wide you wanted each field, 
  939. so you can add new records without having to say CREATE.
  940.  
  941.             SWITCH FILES
  942.   You can switch to a different file. Here's how. . . . 
  943.  
  944.                  USE
  945.   Suppose you create a DBASE file called FAMILIES.DBF, then 
  946. create a DBASE file called FOODS.DBF. If you say LIST, the 
  947. computer will assume you want to list the newest file 
  948. (FOODS.DBF). If you want to list FAMILIES.DBF instead, say:
  949. . USE FAMILIES
  950. . LIST
  951.   Saying USE FAMILIES makes the computer switch its attention to 
  952. FAMILIES.DBF, so that any future command you give (such as LIST 
  953. or GO or DISPLAY) applies to FAMILIES.DBF. To switch to FOODS.DBF 
  954. again, say USE FOODS.
  955.   If you QUIT using DBASE but return to DBASE later, the computer 
  956. forgets which file you were using. Before saying LIST, say USE 
  957. FAMILIES or USE FOODS.
  958.  
  959.                  DIR
  960.   To see a directory of all the files in your hard disk's DBASE 
  961. folder, say:
  962. . DIR *.*
  963.   To see a special directory of just your DBASE data files (which 
  964. end in .DBF), say just:
  965. . DIR
  966. That makes the computer print a special directory showing each 
  967. data file's name, how many records it contains, how many bytes it 
  968. contains, and the date it was last changed.
  969.  
  970.                 COPY
  971.   Suppose you're using the FAMILIES.DBF file, and want to make a 
  972. backup copy of it.
  973.   If you want the backup copy to be called FRED.DBF, say:
  974. . COPY TO FRED
  975. That makes FRED.DBF be an exact copy of the whole file.
  976.   If you want FRED.DBF to include just the records of families 
  977. whose names begin with ``SAN'', say:
  978. . COPY TO FRED FOR NAME="SAN"
  979.   If you want FRED.DBF to include every family's NAME and 
  980. POPULATION but not the INCOME, say:
  981. . COPY TO FRED FIELDS NAME,POPULATION
  982.   If you want FRED.DBF to include no records at all, but just 
  983. have the same structure (the same lengths for all the fields), 
  984. say:
  985. . COPY STRUCTURE TO FRED
  986.   If you want FRED.DBF to contain all the records, but rearranged 
  987. so that the NAMEs are in alphabetical order, say ___ 
  988. . SORT ON NAME TO FRED
  989.   If you want FRED.DBF to contain all the records, but rearranged 
  990. so that the INCOMEs are in increasing order, say ___ 
  991. . SORT ON INCOME TO FRED
  992.   If you want FRED.DBF to contain all the records, but rearranged 
  993. so that the INCOMEs are in decreasing order (from the largest to 
  994. the smallest), say ___ 
  995. . SORT ON INCOME/D TO FRED
  996.                                                        ERASE
  997.                                          If you ever want to 
  998. erase FAMILIES.DBF, say:
  999. . ERASE FAMILIES.DBF
  1000.                                           Hassle While you're in 
  1001. the middle of using FAMILIES.DBF, the computer will refuse to 
  1002. erase it. To stop using it (so you can erase it), tell the 
  1003. computer to use a different file instead (by giving a command 
  1004. such as USE FOODS), or just say ___ 
  1005. .USE
  1006. which makes the computer use no file at all. Then you can say 
  1007. ERASE FAMILIES.DBF.
  1008.  
  1009.                                                  MODIFY STRUCTURE
  1010.                                          When you said CREATE, 
  1011. you filled in a chart: for each field you chose a name (such as 
  1012. INCOME), type (such as Numeric), and width (such as 9).
  1013.                                          If you later want to 
  1014. modify that chart, say:
  1015. . MODIFY STRUCTURE
  1016. The screen will again show the chart that you created. By using 
  1017. the arrow keys, you can move through the chart and modify it. You 
  1018. can change a field's name, type, width, or number of decimal 
  1019. places.
  1020.                                          To delete a field 
  1021. altogether, move to that field, then tap the U key while holding 
  1022. down the CONTROL key. (The U stands for Undo.)
  1023.                                          To insert an extra 
  1024. field, move to where you want the field to be, then tap the N key 
  1025. while holding down the CONTROL key. (The N stands for iNsert 
  1026. New.)
  1027.                                          Change as many fields as 
  1028. you like.
  1029.                                          When you've finished 
  1030. modifying the chart, tap the END key while holding down the 
  1031. CONTROL key. If the computer asks ``Should data be COPIED from 
  1032. backup for all fields?'', tap the Y key.
  1033.                                          The computer will ask, 
  1034. ``Are you sure you want to save these changes?'' Tap the Y key.
  1035.                                          The computer will revise 
  1036. your entire data file, so that the file matches the chart. For 
  1037. example, if you said to make a field wider, the computer will do 
  1038. so by adding extra spaces to your data; if you said to make a 
  1039. field narrower, the computer will do so by abridging your data.
  1040.                                          To see what the computer 
  1041. did to your data file, say LIST.
  1042.                                           Hassle If you make the 
  1043. computer change names of fields, the computer can't reliably 
  1044. change anything else at the same time. So to make lots of 
  1045. changes, say MODIFY STRUCTURE and change names of fields; 
  1046. afterwards say MODIFY STRUCTURE again and make all the other 
  1047. changes you wish (widths, decimal places, types, deleted fields, 
  1048. and extra fields).
  1049.                                           Old versions After 
  1050. giving the MODIFY STRUCTURE command, DBASE 3 and 3+ make your 
  1051. disk contain two versions of your data file. For example, if 
  1052. you've been dealing with FAMILIES.DBF, your disk will contain a 
  1053. file called FAMILIES.DBF (which is the new, modified version), 
  1054. and your disk will also contain a file called FAMILIES.BAK (which 
  1055. is the previous unmodified version). FAMILIES.BAK is called the 
  1056. backup: use it only if you accidentally made a mistake when 
  1057. giving the MODIFY STRUCTURE command. To use FAMILIES.BAK, say:
  1058. . USE
  1059. . ERASE FAMILIES.DBF
  1060. . RENAME FAMILIES.BAK TO FAMILIES.DBF
  1061. . USE FAMILIES
  1062.                                           FOXPRO 2 To move 
  1063. through the chart quickly, use the mouse: click the part of the 
  1064. chart that interests you. To delete a field altogether, click 
  1065. that field then click the word ``Delete''. To insert an extra 
  1066. field, click where you want the field to be then click the word 
  1067. ``Insert''. When you finish modifying the chart, click the word 
  1068. ``OK'' then click the word ``Yes''. Like DBASE 3 and 3+, FOXPRO 2 
  1069. creates a .BAK file; for details, read the paragraph above 
  1070. (entitled ``Old versions'').
  1071.  
  1072.  
  1073.              INDEX FILES
  1074.   Suppose you're using a file called FAMILIES.DBF. Let's play a 
  1075. trick, so that every time you say LIST or DISPLAY the NAMEs will 
  1076. appear in alphabetical order, to help you find a particular NAME 
  1077. very quickly.
  1078.   Say:
  1079. . INDEX ON NAME TO FAMNAME
  1080. That makes the computer create a file called FAMNAME.NDX, which 
  1081. is an iNDeX file that helps the computer find each family's NAME.
  1082.   Then if you say LIST, the computer will list the families in 
  1083. alphabetical order:
  1084. Record#  NAME               INCOME POPULATION
  1085.       2  ANAGNOSTOPOULOS  65143.26          5
  1086.       4  JONES             9873.00          2
  1087.       3  SANCHEZ          50000.00         13
  1088.       6  SANTINI          -4130.15          4
  1089.       1  SMITH            24100.19          4
  1090.       5  SZCZEPANKIEWICZ 125000.00          4
  1091.       7  WONG             15691.18          3
  1092.   In that file, the TOP is record #2: ANAGNOSTOPOULOS. So if you 
  1093. say ___ 
  1094. . GO TOP
  1095. . DISPLAY
  1096. the computer will display:
  1097. Record#  NAME               INCOME POPULATION
  1098.       2  ANAGNOSTOPOULOS  65143.26          5
  1099. Then if you say ___ 
  1100. . SKIP
  1101. . DISPLAY
  1102. the computer will skip the next record in the alphabetized list, 
  1103. and display:
  1104. Record#  NAME               INCOME POPULATION
  1105.       4  JONES             9873.00          2
  1106.   In that alphabetized file, saying GO TOP has a different effect 
  1107. from saying GO 1. If you say GO TOP, you're going to the TOP 
  1108. record, which is ANAGNOSTOPOULOS; if you say GO 1, you're going 
  1109. to the record #1, which is SMITH.
  1110.   If you want to add more records to the alphabetized list, say 
  1111. APPEND. As you type the extra records, the computer will 
  1112. automatically update the index file, so when you say LIST you'll 
  1113. see the entire data file ___ including even the new records ___ 
  1114. in alphabetical order.
  1115.    FOXPRO 2 When you say INDEX ON NAME TO FAMNAME, FOXPRO 2 
  1116. creates an index file called FAMNAME.IDX (instead of 
  1117. FAMNAME.NDX).
  1118.  
  1119.                                                     How to find
  1120.                                          To display the first 
  1121. record whose NAME begins with SAN, you can say:
  1122. . LOCATE FOR NAME="SAN"
  1123. . DISPLAY
  1124.                                          To find that record 
  1125. faster, say this instead ___ 
  1126. . SEEK "SAN"
  1127. . DISPLAY
  1128. or say:
  1129. . FIND SAN
  1130. . DISPLAY
  1131.                                          The only difference 
  1132. between SEEK and FIND is that SEEK must be followed by quotation 
  1133. marks (or a variable), whereas FIND lets you omit the quotation 
  1134. marks.
  1135.                                          SEEK and FIND tell the 
  1136. computer to find the record immediately, by using the index file.
  1137.                                          By contrast, the word 
  1138. LOCATE makes the computer locate the record slowly, by searching 
  1139. through all the records in the whole data file, from beginning to 
  1140. end. If your data file is very long, you'll have to wait a long 
  1141. time for the computer to LOCATE the record! For example, if your 
  1142. data file contains 2,000 records, the LOCATE command takes about 
  1143. 25 times as long as the SEEK and FIND commands. The main reason 
  1144. for creating an index file is so that you can use the words SEEK 
  1145. and FIND.
  1146.                                          Since the index file 
  1147. makes the computer list all the names in alphabetical order, all 
  1148. the SAN names are listed near each other. So after you've found 
  1149. the first SAN (by saying FIND SAN and DISPLAY), you can display 
  1150. the next one immediately, by saying:
  1151. . SKIP
  1152. . DISPLAY
  1153.  
  1154.                                                       Hassles
  1155.                                          If you QUIT or switch to 
  1156. a different data file, and later try to return to FAMILIES.DBF by 
  1157. saying USE FAMILIES, you must remind the computer to look at the 
  1158. index file. Instead of saying just USE FAMILIES, say:
  1159. . USE FAMILIES INDEX FAMNAME
  1160.                                          If you accidentally 
  1161. forget to say INDEX FAMNAME, the computer will forget to look at 
  1162. the index. If you then APPEND or DELETE some records, the 
  1163. computer won't update the index, and the index will be wrong. If 
  1164. you get into that jam, get out of it by saying ___ 
  1165. . USE FAMILIES INDEX FAMNAME
  1166. . REINDEX
  1167. That makes the computer create the index all over again, 
  1168. correctly.
  1169.                                          To see the names of all 
  1170. your index files (such as FAMNAME.NDX), say:
  1171. . DIR *.NDX
  1172.                                           FOXPRO 2 To see the 
  1173. names of all your index files (such as FAMNAME.IDX), say ``DIR 
  1174. *.IDX''.
  1175.  
  1176.  
  1177.               PROGRAMS
  1178.   Let's write a program so that whenever you say DO STATS, the 
  1179. computer will automatically print the SUM and AVERAGE of all the 
  1180. numbers in your data file. Here's how.
  1181.   Begin by saying ___ 
  1182. . MODIFY COMMAND STATS
  1183. That tells the computer you want to write a program called 
  1184. STATS.PRG.
  1185.   Next, say what you want STATS to stand for. If you want STATS 
  1186. to stand for ``the SUM followed by the AVERAGE'', type:
  1187. SUM
  1188. AVERAGE
  1189. That pair of instructions (SUM and AVERAGE) is called the 
  1190. program. The computer does not put a dot prompt in front of the 
  1191. program lines.
  1192.   While you're typing the program, you can edit it by using the 
  1193. arrow keys and all the other word-processing keys (DELETE, 
  1194. INSERT, PAGE UP, and PAGE DOWN).
  1195.   To hop to the left margin, press the HOME key. To hop to the 
  1196. end of a line, press the END key.
  1197.   To delete a line, move to that line, then tap the Y key while 
  1198. holding down the CONTROL key. (The Y stands for ``Yank it out''.) 
  1199. To insert an extra line between two other lines, move to where 
  1200. you want the extra line to begin, then tap the N key while 
  1201. holding down the CONTROL key. (The N stands for ``iNsert New''.)
  1202.   When you've finished typing and editing the program, tap the 
  1203. END key while holding down the CONTROL key. That makes the 
  1204. computer put the entire program onto the disk. Then the screen 
  1205. will show a dot prompt.
  1206.   If you want the computer to DO the STATS program you typed, 
  1207. say:
  1208. . DO STATS
  1209. Then the computer will print the SUM and AVERAGE of all the 
  1210. numbers in the current data file. For example, if you've been 
  1211. using the FAMILIES data file, the computer will print the SUM of 
  1212. the INCOMEs, SUM of the POPULATIONs, AVERAGE of the INCOMEs, and 
  1213. AVERAGE of the POPULATIONs. (If you haven't been using a data 
  1214. file, the computer will ask you which file to USE. If your data 
  1215. file doesn't contain any Numeric fields, the computer will 
  1216. gripe.)
  1217.   If you ever want to revise that program, just say MODIFY 
  1218. COMMAND STATS again. The screen will show your program again and 
  1219. let you edit it. When you've finished editing it, tap the END key 
  1220. while holding down the CONTROL key. The new version of your 
  1221. program will be called STATS.PRG; the previous version of your 
  1222. program will still be on the disk but will be called STATS.BAK.
  1223.   For another example, let's program the computer so that when 
  1224. you say DO SUPERDIR, the computer will print a superdirectory. 
  1225. Let's make the superdirectory include a directory of all your 
  1226. data files, followed by a directory of all your index files, 
  1227. followed by a directory of all your program files.
  1228.   To make DO SUPERDIR accomplish all that, say:
  1229. . MODIFY COMMAND SUPERDIR
  1230. Then type this program ___ 
  1231. DIR
  1232. DIR *.NDX
  1233. DIR *.PRG
  1234. End the program by tapping the END key while holding down
  1235. the CONTROL key. From then on, whenever you say DO SUPERDIR, the 
  1236. computer will print a superdirectory.
  1237.                                          Into a program, you can 
  1238. put any DBASE commands you wish. For example, your program can 
  1239. include a USE command (to switch to a different data file), an 
  1240. APPEND command (to let the user add extra records to the file), 
  1241. and a BROWSE command (to let the user browse through the entire 
  1242. file and edit it).
  1243.                                          One of the lines in your 
  1244. program can even say DO a second program. When the computer 
  1245. encounters that line, the computer will DO the second program, 
  1246. then finish the original program.
  1247.                                          Your program's bottom 
  1248. line can even say QUIT, so that when the computer finishes the 
  1249. program it will stop using DBASE.
  1250.                                           Old versions In DBASE 
  1251. 3 and 3+, here's how to hop to the left margin: tap the 
  1252. left-arrow key while holding down the CONTROL key. Here's how to 
  1253. hop to the end of the line: tap the right arrow key while holding 
  1254. down the CONTROL key.
  1255.                                           FOXPRO 2 Saying 
  1256. ``MODIFY COMMAND STATS'' makes the computer create a window 
  1257. called ``STATS.PRG''. In that window, type your program, like 
  1258. this:
  1259. SUM
  1260. AVERAGE
  1261.                                          To insert an extra line, 
  1262. move to where you want the extra line to begin, then press ENTER. 
  1263. To delete a line, move to the beginning of that line, press SHIFT 
  1264. with down-arrow (so the line becomes brown), then press DELETE.
  1265.                                          When you've finished 
  1266. typing and editing the program, click the close box then click 
  1267. ``Yes''.
  1268.                                          In the SUPERDIR program, 
  1269. say ``DIR *.IDX'' instead of ``DIR *.NDX''.
  1270.  
  1271.                                                        TEXT
  1272.                                          Let's program the 
  1273. computer so that whenever you say DO POEM, the computer will 
  1274. print this poem:
  1275. YOUR DATA FILES
  1276. ALL GIVE ME SMILES.
  1277. I FEEL SO LOW,
  1278. WHEN THEY MUST GO.
  1279. PLEASE DON'T ERASE
  1280. YOUR DATABASE!
  1281.         LOVE,
  1282.         YOUR COMPUTER
  1283.                                          Here's how:
  1284. . MODIFY COMMAND POEM
  1285. ? "YOUR DATA FILES"
  1286. ? "ALL GIVE ME SMILES."
  1287. ? "I FEEL SO LOW,"
  1288. ? "WHEN THEY MUST GO."
  1289. ? "PLEASE DON'T ERASE"
  1290. ? "YOUR DATABASE!"
  1291. ? "        LOVE,"
  1292. ? "        YOUR COMPUTER"
  1293.                                          But typing all those 
  1294. question marks and quotation marks is ridiculous! For a 
  1295. short-cut, type this instead:
  1296. . MODIFY COMMAND POEM
  1297. TEXT
  1298. YOUR DATA FILES
  1299. ALL GIVE ME SMILES.
  1300. I FEEL SO LOW,
  1301. WHEN THEY MUST GO.
  1302. PLEASE DON'T ERASE
  1303. YOUR DATABASE!
  1304.         LOVE,
  1305.         YOUR COMPUTER
  1306. ENDTEXT
  1307. The words TEXT and ENDTEXT tell the computer that everything 
  1308. between them should be printed as strings. To begin an indented 
  1309. passage (such as LOVE and YOUR COMPUTER), press the TAB key. 
  1310. Pressing the TAB key
  1311. makes the computer indent the current line and all lines 
  1312. underneath, until you tell the computer to stop indenting (by 
  1313. pressing SHIFT with TAB).
  1314.    Old versions In DBASE 3 and 3+, pressing the TAB key makes 
  1315. the computer indent just 4 spaces (instead of 8). Pressing the 
  1316. TAB key makes the computer indent just the current line (not the 
  1317. lines underneath).
  1318.    FOXPRO 2 Pressing the TAB key makes the computer indent just 
  1319. 4 spaces (instead of 8). To tell the computer to stop indenting, 
  1320. press the BACKSPACE key.
  1321.  
  1322.             Tricky output
  1323.   Here are some commands you can put in your program, to produce 
  1324. tricky output.
  1325.   To erase the screen, say:
  1326. CLEAR
  1327.   If you say ___ 
  1328. ? "FAT"
  1329. ?? "HER"
  1330. the double question mark makes the computer print HER on the same 
  1331. line as FAT. The computer will print:
  1332. FATHER
  1333.   When using DBASE, the screen's top line is called line 0. Then 
  1334. come lines 1, 2, etc. In each line, the leftmost character is at 
  1335. position 0. Then come positions 1, 2, etc. To print the word 
  1336. DROWN beginning at line 3's 7th position, type this:
  1337. @3,7 SAY "DROWN"
  1338.   SET HEADING OFF When you say LIST, DISPLAY, SUM, or AVERAGE, 
  1339. the computer prints data in columns and puts a heading at the top 
  1340. of each column. If you want the computer to omit the headings, 
  1341. say:
  1342. SET HEADING OFF
  1343. That command remains in effect until you say SET HEADING ON (or 
  1344. QUIT).
  1345.   To invent your own customized heading, first get rid of the 
  1346. traditional headings (by saying SET HEADING OFF) and then print 
  1347. your own headings (by giving the ``?'' or ``@SAY'' commands).
  1348.   SET TALK OFF While running your program, the computer prints 
  1349. messages telling you which records and numbers it's manipulating.
  1350.   For example, if you say GO 3 and then SKIP 2, the computer 
  1351. prints a message saying it's skipping to record #5. If you say to 
  1352. COPY a file, the computer prints messages telling you how many 
  1353. records it's copied so far, until all the records are copied.
  1354.   Those messages help DBASE programmers but confuse business 
  1355. executives who don't understand the messages' jargon. To stop the 
  1356. computer from printing those messages, say:
  1357. SET TALK OFF
  1358. That command remains in effect until you say SET TALK ON.
  1359.   If you say SET TALK OFF, you'll have a hard time doing 
  1360. statistics: the simple COUNT, SUM, and AVERAGE commands don't 
  1361. work until you say SET TALK ON.
  1362.  
  1363.               Variables
  1364.   Like BASIC, DBASE lets you use variables easily. For example, 
  1365. if you say ___ 
  1366. X=7-1
  1367. ? X+3
  1368. the computer will print 9.
  1369.                                          (While the computer 
  1370. performs X=7-1, the computer will also print a little message 
  1371. saying that X is 6, unless you say SET TALK OFF.)
  1372.                                          A variable's name can be 
  1373. short (such as X) or longer. It can be up to 10 characters long 
  1374. (such as POPULATION). It can include underlines and digits (such 
  1375. as LOST_IN_86). It must begin with a letter. It cannot include 
  1376. blank spaces.
  1377.                                          A variable can stand for 
  1378. either a number or a string. For example, if you say ___ 
  1379. HUSBAND="TOM"
  1380. ? HUSBAND
  1381. the computer will print TOM.
  1382.                                          The computer handles two 
  1383. kinds of variables. A field variable stands for a field in a data 
  1384. file. For example, while you're using FAMILIES.DBF, you're using 
  1385. field variables called NAME, INCOME, and POPULATION. A memory 
  1386. variable is any variable that does not stand for a field. For 
  1387. example, if you say X=7-1, the X is a memory variable.
  1388.                                          Suppose you're using 
  1389. FAMILIES.DBF, so INCOME is a field variable. to change a family's 
  1390. INCOME to 20000, do not say INCOME=20000. Instead, say:
  1391. REPLACE INCOME WITH 20000
  1392. Here's the rule: to change the value of a memory variable, say 
  1393. ``=''; to change the value of a field variable, say ``REPLACE''.
  1394.                                          The computer will 
  1395. remember all your variables until you say CLEAR MEMORY (which 
  1396. erases the memory variables) or say to USE a different data file 
  1397. (which affects the field variables) or say CLEAR ALL (which 
  1398. erases all the variables and also makes the computer forget which 
  1399. file you were USEing).
  1400.                                          The typical DBASE 
  1401. program begins by saying CLEAR ALL and ends by saying CLEAR ALL 
  1402. again, to make sure the variables from different programs don't 
  1403. interfere with each other.
  1404.                                          STORE Instead of saying 
  1405. X=7-1, you can say STORE 7-1 TO X. Saying ``STORE 7-1 TO X'' has 
  1406. exactly the same effect as saying ``X=7-1''.
  1407.                                          To make X, Y, and Z all 
  1408. be zero, say:
  1409. STORE 0 TO X,Y,Z
  1410.                                          Statistics To make X be 
  1411. the SUM of all the INCOMEs in your data file, say:
  1412. SUM INCOME TO X
  1413. To make X be the SUM of all the INCOMEs and also make Y be the 
  1414. sum of all the POPULATIONs, say:
  1415. SUM INCOME, POPULATION TO X,Y
  1416. Similar commands work for COUNT and AVERAGE also. They all work 
  1417. even if you SET TALK OFF.
  1418.  
  1419.                                                        INPUT
  1420.                                          Like BASIC, DBASE 
  1421. understands the word INPUT. If you say ___ 
  1422. INPUT "HOW OLD ARE YOU? " TO AGE
  1423. the computer will ask ___ 
  1424. HOW OLD ARE YOU?
  1425. and then wait for you to type a number. Whatever number you type 
  1426. will become the AGE.
  1427.   The INPUT statement's variable must be a memory variable, not a 
  1428. field variable. For example, if you're using FAMILIES.DBF and 
  1429. want the person to input an INCOME (which is a field variable), 
  1430. you must not say INPUT ``WHAT IS YOUR INCOME?'' TO INCOME. 
  1431. Instead, input a memory variable called MINCOME, then copy it to 
  1432. a field by saying REPLACE, like this:
  1433. INPUT "WHAT IS YOUR INCOME? " TO MINCOME
  1434. REPLACE INCOME WITH MINCOME
  1435.  
  1436.                ACCEPT
  1437.   To input a string instead of a number, say ACCEPT instead of 
  1438. INPUT:
  1439. ACCEPT "WHAT IS YOUR FAVORITE FOOD? " TO FOOD
  1440.   Underneath that ACCEPT statement, you might want to add this 
  1441. line:
  1442. FOOD=UPPER(FOOD)
  1443. It makes the computer convert the human's input to capital 
  1444. (upper-case) letters, in case the human forgot to press the CAPS 
  1445. LOCK key.
  1446.   Like the INPUT statement, the ACCEPT statement takes a memory 
  1447. variable but not a field variable.
  1448.  
  1449.                 WAIT
  1450.   This example says WAIT instead of ACCEPT:
  1451. WAIT "WHAT'S YOUR MIDDLE INITIAL? " TO INITIAL
  1452. ? "CONGRATULATIONS!"
  1453. ? "ACCORDING TO ASTROLOGY, THE FORCES OF THE UNIVERSE"
  1454. ? "SHALL CAUSE WONDROUS JOYS TO BEFALL"
  1455. ? "THOSE LUCKY PERSONS WHOSE EARTH-GIVEN NAMES ARE CENTERED"
  1456. ? "AROUND THE LETTER",INITIAL
  1457.   WAIT resembles ACCEPT. In that program, the first line makes 
  1458. the computer ask ``WHAT'S YOUR MIDDLE INITIAL?'' then wait for 
  1459. you to type a character. Whatever character you type will become 
  1460. the INITIAL. For example, if you type a Q, the Q will become the 
  1461. INITIAL.
  1462.   If the line had said ACCEPT, the computer would have required 
  1463. you to press the ENTER key after the Q. But since the line said 
  1464. WAIT instead of ACCEPT, you do not have to press ENTER: as soon 
  1465. as you type the Q, the computer will know Q is the INITIAL 
  1466. (without waiting for ENTER) and will make the screen show this:
  1467. WHAT'S YOUR MIDDLE INITIAL? Q
  1468. CONGRATULATIONS! ACCORDING TO ASTROLOGY, THE FORCES OF THE 
  1469. UNIVERSE
  1470. SHALL CAUSE WONDROUS JOYS TO BEFALL
  1471. THOSE LUCKY PERSONS WHOSE EARTH-GIVEN NAMES ARE CENTERED
  1472. AROUND THE LETTER Q
  1473.   WAIT is nicer than ACCEPT, because WAIT doesn't force you to 
  1474. press the ENTER key after answering the question. But alas, WAIT 
  1475. restricts you to typing just one character: you can use WAIT for 
  1476. a middle initial, but not for a whole name.
  1477.  
  1478.                  GET
  1479.   Suppose you live in San Francisco with most of your friends, 
  1480. but a few of your friends live elsewhere. Run this program:
  1481. CLEAR ALL
  1482. CLEAR
  1483. SET TALK OFF
  1484. CITY="SAN FRANCISCO"
  1485. STATE="CA"
  1486. @10,25 SAY "WHAT IS YOUR CITY?" GET CITY
  1487. @11,25 SAY "WHAT IS YOUR STATE?" GET STATE
  1488. READ
  1489. ? "I AM GLAD TO HEAR YOU LIVE IN THE KOOKY CITY OF",CITY
  1490. ? "IN THE SEDUCTIVE STATE OF",STATE
  1491. SET TALK ON
  1492. CLEAR ALL
  1493.                                          Like most DBASE 
  1494. programs, that program begins by saying CLEAR ALL (to avoid 
  1495. interference from other programs), CLEAR (to erase the screen), 
  1496. and SET TALK OFF (to avoid excessive messages).
  1497.                                          The next pair of lines 
  1498. make CITY be ``SAN FRANCISCO'' and make STATE be ``CA''.
  1499.                                          The next pair of lines 
  1500. put this message in the middle of your screen:
  1501.                          WHAT IS YOUR CITY? SAN FRANCISCO
  1502.                          WHAT IS YOUR STATE? CA
  1503.                                          The READ statement lets 
  1504. you edit the data in the boxes, by using the arrow keys, ENTER 
  1505. key, and other word-processing keys. (If you want to erase an 
  1506. entire box, move to that box, then tap the Y key while holding 
  1507. down the CONTROL key.) You can edit the boxes however you like 
  1508. ___ for example, change SAN FRANCISCO to RENO, and change CA to 
  1509. NV ___ or do no editing at all, so that you still have SAN 
  1510. FRANCISCO and CA. When you've finished doing all the editing you 
  1511. wish, tap the END key while holding down the CONTROL key, or just 
  1512. move to the bottom box and tap the ENTER key.
  1513.                                          If you changed SAN 
  1514. FRANCISCO to RENO and changed CA to NV, the next two lines in the 
  1515. program will print this, at the bottom of the screen:
  1516. I AM GLAD TO HEAR YOU LIVE IN THE KOOKY CITY OF RENO
  1517. IN THE SEDUCTIVE STATE OF NV
  1518.                                          Like most DBASE 
  1519. programs, that program ends by putting the computer back to its 
  1520. normal state (SET TALK ON and CLEAR ALL).
  1521.                                          To use the word GET, you 
  1522. should put it in an @ SAY command. Underneath the @ SAY GET 
  1523. commands, say READ.
  1524.                                          If you forget to include 
  1525. the SAY ``WHAT IS YOUR CITY?'', and instead type just @10,25 GET 
  1526. CITY, the computer will omit the question but will still show the 
  1527. CITY box. If you forget to say READ, you'll still see boxes full 
  1528. of data, but you won't get a chance to edit what's in them.
  1529.                                          By using GET and READ, 
  1530. you can edit any kind of variable. The variable can be a number 
  1531. or a string; it can be a memory variable or a field variable.
  1532.                                          If it's a field 
  1533. variable, the computer automatically makes the box wide enough to 
  1534. hold the entire field; and when you edit the data in the box, the 
  1535. computer automatically updates your data file. (You do not have 
  1536. to say REPLACE.)
  1537.                                          If it's a memory 
  1538. variable instead, your program must include a statement such as 
  1539. CITY=``SAN FRANCISCO'', which tells the computer how wide to make 
  1540. the box. To make the box even wider, put extra spaces after SAN 
  1541. FRANCISCO, like this:
  1542. CITY="SAN FRANCISCO         "
  1543. If the memory variable stands for a number instead of a string, 
  1544. the computer automatically makes the box wide enough to hold 10 
  1545. digits before the decimal point ___ or even wider.
  1546.  
  1547.     CONTROL THE FLOW
  1548.   You can control the order in which the computer does your 
  1549. program's statements. Here's how. . . . 
  1550.  
  1551.            IF
  1552.   Like BASIC and PASCAL, DBASE lets you use the words IF and 
  1553. ELSE. Write the IF statement like this:
  1554. IF AGE<18
  1555.         ? "MINOR"
  1556.         ? "YOUNG"
  1557. ELSE
  1558.         ? "ADULT"
  1559.         ? "OLD"
  1560. ENDIF
  1561.   Whenever you say IF, you must also say ENDIF. To indent the 
  1562. lines in between, tap the TAB key. (The indentation is optional.)
  1563.   Here's how to say, ``If the NAME begins with SAN and the INCOME 
  1564. is at least 50000'':
  1565. IF NAME="SAN" .AND. INCOME>=50000
  1566. Remember to put periods around the word AND. For strings, the 
  1567. symbol ``='' means ``begins with'', unless you said SET EXACT ON.
  1568.  
  1569.         DO WHILE
  1570.   To create a loop, say DO WHILE. If you want the loop to be 
  1571. infinite, say DO WHILE .T., like this:
  1572. DO WHILE .T.
  1573.         ? "CAT"
  1574.         ? "DOG"
  1575. ENDDO
  1576. The computer will print CAT and DOG repeatedly, like this:
  1577. CAT
  1578. DOG
  1579. CAT
  1580. DOG
  1581. CAT
  1582. DOG
  1583. etc.
  1584. To abort the program, tap the Esc key (which stands for 
  1585. ``Escape'') and then the C key (which stands for ``Cancel'').
  1586.   Any program that says DO WHILE must also say ENDDO. The 
  1587. computer will repeat all the lines between DO WHILE and ENDDO, to 
  1588. form a loop.
  1589.   This program makes the computer print all the numbers from 1 to 
  1590. 10 and then print ``WOW'':
  1591. SET TALK OFF
  1592. X=1
  1593. DO WHILE X<=10
  1594.         ? X
  1595.         X=X+1
  1596. ENDDO
  1597. ? "WOW"
  1598. SET TALK ON
  1599. The top line prevents the computer from printing excessive 
  1600. messages. The next line says X starts at 1. The lines between DO 
  1601. WHILE and ENDDO are done repeatedly, as long as X<=10. If X gets 
  1602. past 10, the computer refuses to do the loop again, and instead 
  1603. proceeds to the line underneath ENDDO, which makes the computer 
  1604. say WOW. The bottom of the program says SET TALK ON, to put the 
  1605. computer back to normal. Altogether, the computer prints:
  1606.          1
  1607.          2
  1608.          3
  1609.          4
  1610.          5
  1611.          6
  1612.          7
  1613.          8
  1614.          9
  1615.         10
  1616. WOW
  1617.                              In BASIC, you can create loops by 
  1618. giving commands such as ``GO TO 10'' and ``FOR I = 1 TO 
  1619. 10...NEXT''. Unfortunately, DBASE doesn't understand how to GO TO 
  1620. line 10 or how to do a FOR...NEXT loop. In DBASE, the only way to 
  1621. create a loop is to say DO WHILE...ENDDO.
  1622.                              In the middle of a WHILE loop, you 
  1623. can put a line saying LOOP or EXIT. If the computer encounters a 
  1624. line saying LOOP, the computer loops back (by jumping back to the 
  1625. WHILE loop's top line). If the computer encounters a line saying 
  1626. EXIT, the computer exits from the loop (by jumping ahead to the 
  1627. line underneath ENDDO).
  1628.  
  1629.                                                 RETURN
  1630.                              Instead of using the BASIC word END, 
  1631. DBASE uses the word RETURN.
  1632.                              While the computer is DOing your 
  1633. program, if the computer encounters a line that says RETURN, the 
  1634. computer will skip the rest of the program.
  1635.  
  1636.                                          The ULTIMATE program
  1637.                              Congratulations! Now you know enough 
  1638. about DBASE so that you're ready to create the ULTIMATE program. 
  1639. This program lets you store and retrieve any information about 
  1640. any topic! Moreover, the program is so nicely designed that even 
  1641. a novice who knows nothing about DBASE can run the program and 
  1642. use its full power.
  1643.                              How the program acts After you've 
  1644. written the program, you can start using it by just typing:
  1645. . DO ULTIMATE
  1646. Then the computer starts running the ULTIMATE program, which 
  1647. makes the computer ask:
  1648. What topic interests you? (If unsure, type a question mark. To 
  1649. end, type an x.)
  1650.                              If you type just an x or a capital 
  1651. X, the computer stops running the program and displays the dot 
  1652. prompt.
  1653.                              If you type a question mark instead, 
  1654. the computer displays a list of all the topics it was fed 
  1655. previously. For example, those topics might include SHRUB, BUSH, 
  1656. QUAIL, BIRDBRAIN, MANHATTAN, SEX, THE MEANING OF LIFE, and 
  1657. STRANGE JOKES. Then the computer says:
  1658. Pick one of those topics, or teach me a new one.
  1659.  
  1660. What topic interests you? (If unsure, type a question mark. To 
  1661. end, type an x.)
  1662.                              If you type anything other than an x 
  1663. or an X or a question mark, the computer searches through its 
  1664. file, to see whether it's been fed that topic. If it finds the 
  1665. topic in the file, it reveals all it knows about the topic, and 
  1666. then lets you edit that data. If it does not find the topic in 
  1667. the file, it says so, and gives you an opportunity to teach it 
  1668. about the topic.
  1669.   How to invent the program To make the computer do all that, so 
  1670. a novice can store and retrieve data easily, a professional (such 
  1671. as yourself!) must previously put three things onto the disk: the 
  1672. program itself (which is called ULTIMATE.PRG), a data file 
  1673. (called INFO.DBF), and an index file (called INFOTOP.NDX). Here's 
  1674. how. . . . 
  1675.   Data file Start by putting the data file INFO.DBF onto the 
  1676. disk. To do that, say:
  1677. . CREATE INFO
  1678. Then complete this chart:
  1679. ┌─────┬────────────┬────────────┬───────┬─────┬───────┐
  1680. │ Num │ Field Name │ Field Type │ Width │ Dec │ Index │
  1681. ╞═════╪════════════╪════════════╪═══════╪═════╪═══════╡
  1682. │   1 │ TOPIC      │ Character  │   25  │     │   N   │
  1683. │   2 │ DATA       │ Character  │   79  │     │   N   │
  1684. │     │            │            │       │     │       │
  1685. │     │            │            │       │     │       │
  1686. │     │            │            │       │     │       │
  1687. └─────┴────────────┴────────────┴───────┴─────┴───────┘
  1688. That allows each TOPIC to be 25 characters long, and the DATA 
  1689. about the topic to be 79 characters long.
  1690.   After typing the chart, tap the END key while holding down the 
  1691. CONTROL key. Then tap the ENTER key. The computer will ask, 
  1692. ``Input data records now?'' Tap the N key.
  1693.   Index file Next, put the index file INFOTOP.NDX onto the disk, 
  1694. by typing:
  1695. . INDEX ON TOPIC TO INFOTOP
  1696. That creates an index file called INFOTOP.NDX, which lets the 
  1697. computer find each TOPIC quickly.
  1698.   The program itself Finally, put the program ULTIMATE.PRG onto 
  1699. the disk. To do that, begin by saying:
  1700. . MODIFY COMMAND ULTIMATE
  1701.   Then type the program's introduction:
  1702. CLEAR ALL
  1703. CLEAR
  1704. SET TALK OFF
  1705. SET HEADING OFF
  1706. SET EXACT ON
  1707. SET DELETED ON
  1708. USE INFO INDEX INFOTOP
  1709. That introduction says to CLEAR ALL influences from previous 
  1710. programs, CLEAR the screen, SET the DBASE program so you have 
  1711. complete control over everything, and USE the INFO data file 
  1712. INDEXed by INFOTOP.
  1713.   Then type the program's loop:
  1714. DO WHILE .T.
  1715.         ?
  1716.         ?"What topic interests you? "
  1717.         ?? "(If unsure, type a question mark. To end, type an 
  1718. x.)"
  1719.         ACCEPT TO DESIRE
  1720.         DESIRE=UPPER(DESIRE)
  1721.         CLEAR
  1722.         DO CASE
  1723.         CASE DESIRE="X"
  1724.                 EXIT
  1725.         CASE DESIRE="?"
  1726.                 GO TOP
  1727.                 IF EOF()
  1728.                         ? "I don't know any topics yet. My mind 
  1729. is blank. "
  1730.                         ?? "Please teach me a new topic."
  1731.                 ELSE
  1732.                         ? "I know about these topics:"
  1733.                         DISPLAY ALL OFF TOPIC
  1734.                         ? "Pick one of those topics, or teach me 
  1735. a new one."
  1736.                 ENDIF
  1737.  
  1738.         CASE DESIRE=""
  1739.         OTHERWISE
  1740.                 SEEK DESIRE
  1741.                 IF FOUND()
  1742.                         ? "Here's what I know about",DESIRE+":"
  1743.                         @2,0 GET DATA
  1744.                         ? "You can edit that info now."
  1745.                         ? "(If you want me to forget 
  1746. about",DESIRE
  1747.                         ?? ", tap Y while holding down the CTRL 
  1748. key.)"
  1749.                         ? "When you're done, tap the ENTER key."
  1750.                         READ
  1751.                         CLEAR
  1752.                         IF DATA=""
  1753.                                 DELETE
  1754.                         ENDIF
  1755.                 ELSE
  1756.                         ? "I don't know anything 
  1757. about",DESIRE+"."
  1758.                         ? "Tell me about",DESIRE+"."
  1759.                         ? "(If you don't want to tell me, type an 
  1760. x.)"
  1761.                         ACCEPT TO NEWDATA
  1762.                         IF UPPER(NEWDATA)#"X"
  1763.                                 APPEND BLANK
  1764.                                 REPLACE TOPIC WITH DESIRE
  1765.                                 REPLACE DATA WITH NEWDATA
  1766.                         ENDIF
  1767.                 ENDIF
  1768.         ENDCASE
  1769. ENDDO
  1770.   In that loop, each print statement uses small letters instead 
  1771. of capitals, so that the printing will look more sophisticated. 
  1772. (To create the small letters, just turn off the CAPS LOCK key, by 
  1773. tapping it.)
  1774.   After saying ACCEPT TO DESIRE, the next statement says 
  1775. DESIRE=UPPER(DESIRE), which converts the user's desired topic to 
  1776. capital letters. That saves the user from worrying about whether 
  1777. to type REAGAN or Reagan or reagan: whichever of those the user 
  1778. types, the computer will convert it to REAGAN.
  1779.   The DESIRE can be four kinds of things: it can be an X (which 
  1780. means the user wants to exit), a question mark (which means the 
  1781. user is confused and would like to see a list of topics), nothing 
  1782. at all (which means the user accidentally pressed the ENTER key 
  1783. an extra time), or a topic. The DO CASE statement tells the 
  1784. computer to handle those four cases: DESIRE=``X'', DESIRE=``'', 
  1785. and DESIRE=otherwise. Let's look at those four cases in more 
  1786. detail.
  1787.   In the CASE where DESIRE=``X'', the computer lets the user EXIT 
  1788. from the DO WHILE loop.
  1789.   In the CASE where DESIRE=``?'', the computer begins by checking 
  1790. whether the file contains any undeleted topics. Here's how. The 
  1791. lines GO TOP and IF EOF() tell the computer to GO to the TOP of 
  1792. the file and see if the TOP of the file is also the End Of the 
  1793. File. If the TOP of the file is also the End Of the File, the 
  1794. file doesn't contain any records yet (or all its records have 
  1795. been DELETED), so the computer will print ``I don't know any 
  1796. topics yet. My mind is blank.'' If the computer's mind is not 
  1797. blank, the computer will say ``I know about these topics'' and 
  1798. will DISPLAY ALL of the TOPICS. The computer will display the 
  1799. topics themselves but will not display their record numbers, 
  1800. since the DISPLAY statement says to turn the record numbers OFF.
  1801.   In the CASE where DESIRE=``'', the computer does nothing at 
  1802. all.
  1803.   In the case where desire is OTHERWISE, the computer will hunt 
  1804. through all the topics in the file, to SEEK the user's DESIRE.
  1805.   If the user's DESIRE is FOUND in the file, the computer is 
  1806. commanded to print ``Here's what I know about'',DESIRE+``:''. In 
  1807. that command, the word DESIRE is followed by a plus sign instead 
  1808. of a comma, to prevent the computer from leaving a blank space 
  1809. after DESIRE.
  1810.   If the user's DESIRE is not FOUND in the file, the computer is 
  1811. commanded to print ``I don't know anything about'',DESIRE+``.''. 
  1812. Then the computer asks the user to type some NEWDATA about the 
  1813. topic. If the user does indeed type some useful NEWDATA (instead 
  1814. of just an X), the computer appends the NEWDATA to the end of the 
  1815. file. To do that, the computer first APPENDs a BLANK record, then 
  1816. puts the NEWDATA into that record by using REPLACE.
  1817.   The remaining lines say ENDIF twice (to end the two IF 
  1818. statements) and ENDCASE (to end the DO CASE statement) and ENDDO 
  1819. (to end the DO WHILE statement).
  1820.                                                      At the 
  1821. bottom of the program, add these lines:
  1822. SET DELETED OFF
  1823. COUNT FOR DELETED() TO DELCOUNT
  1824. IF DELCOUNT>RECCOUNT()/4
  1825.         ? "Please wait, "
  1826.         ?? "while I compress your data."
  1827.         PACK
  1828.         ? "The compression is done."
  1829. ENDIF
  1830. SET EXACT OFF
  1831. SET HEADING ON
  1832. SET TALK ON
  1833. CLEAR ALL
  1834. The computer reaches those lines when the user chooses to EXIT 
  1835. from the DO WHILE loop (by saying the DESIRE is ``X''). Those 
  1836. lines say to SET the computer back to normal and to CLEAR ALL 
  1837. interference from later programs.
  1838.                                                      One of those 
  1839. lines says to PACK the file. But if fewer than a quarter of the 
  1840. records have been marked for deletion, the program tells the 
  1841. computer not to bother PACKing.
  1842.                                                      Here's how 
  1843. the computer figures out whether to bother PACKing. The program 
  1844. says to COUNT how many records have been marked to be DELETED, 
  1845. and call that the DELCOUNT. The program says that IF the DELCOUNT 
  1846. is greater than the RECord COUNT divided by 4, then PACK.
  1847.                                                      After you've 
  1848. typed that entire program, tap the END key while holding down the 
  1849. CONTROL key. Then you're done: you've created the ULTIMATE 
  1850. data-management program!
  1851.                                                      Consequences 
  1852. Some parts of that program were hard to invent, but the program 
  1853. is super-easy to use. Try it!
  1854.                                                      Then 
  1855. challenge yourself: think of further improvements to the ULTIMATE 
  1856. program, to make the program even easier to use and even more 
  1857. powerful!
  1858.                                                      Such 
  1859. programs would be much harder to develop, if we were using BASIC, 
  1860. LOGO, PASCAL, C, COBOL or any other major computer language. 
  1861. That's why programmers love DBASE!
  1862.                                                       Old 
  1863. versions DBASE 3 doesn't understand RECCOUNT(); instead of saying 
  1864. IF DELCOUNT>RECCOUNT()/4, say COUNT TO RECCOUNT and then IF 
  1865. DELCOUNT>RECCOUNT/4.
  1866.                                                      DBASE 3 
  1867. doesn't understand the word FOUND. DBASE 3+ version 1.0 handles 
  1868. FOUND incorrectly if you deleted some records. For those versions 
  1869. of DBASE, instead of saying IF FOUND(), say IF .NOT. EOF().
  1870.